//
//  Person.m
//  06集合遍历和数组排序HomeWork
//
//  Created by dllo on 16/7/8.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "Person.h"

@implementation Person
- (instancetype)initWithName:(NSString *)name age:(NSInteger)age sex:(NSString *)sex{
    self = [super init];
    if (self) {
        _name = name;
        _age = age;
        _sex = sex;
    }
    return self;
}

+ (instancetype)personWithName:(NSString *)name age:(NSInteger)age sex:(NSString *)sex{
    return [[Person alloc] initWithName:name age:age sex:sex];
}

- (NSString *)description
{
    return [[NSString alloc] initWithFormat:@"%@",_name];
}


- (NSComparisonResult)compareByName:(Person *)anotherPerson
{
    return [self.name compare:anotherPerson.name];
}

- (NSComparisonResult)compareByAge:(Person *)anotherPerson
{
    
    return self.age > anotherPerson.age;
}

- (NSComparisonResult)compareBySex:(Person *)anotherPerson
{
    return [self.sex compare:anotherPerson.sex];
}




@end
